<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.wl.shixun3.entity.User" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录成功</title>
    <link rel="stylesheet" href="../css/success.css" type="text/css">
</head>
<body>
    <div class="container">

            <h2>登录成功</h2>
            <%
                User user = (User) session.getAttribute("user");
                String username = (String) session.getAttribute("username");
                String loginTime = (String) session.getAttribute("loginTime");
                
                if (user != null && username != null) {
            %>
            <h3>用户：<strong><%= username %></strong>登录成功！</h3>

            <% } else { %>
                <p>会话已失效，请重新登录。</p>
                <script>
                    setTimeout(function() {
                        window.location.href = "login.jsp";
                    }, 2000);
                </script>
            <% } %>

        
        <% if (user != null) { %>
        <h3 style="margin-top: 0; color: #667eea;">账号信息</h3>
        <p><strong>用户名：</strong><%= user.getUsername() %></p>
        <p><strong>登录时间：</strong><%= loginTime != null ? loginTime : "未知" %></p>
        <p><strong>安全问题：</strong><%= user.getSecurityQuestion() %></p>

        
        <div class="action-buttons">
            <a href="changePassword.jsp" class="btn" style="display: inline-block; margin-top: 20px;">修改密码</a>
            <a href="logout" class="btn logout-btn" style="display: inline-block;">退出登录</a>
        </div>
        
        <div style="text-align: center; color: #666; margin-top: 30px; padding: 20px; background-color: #fff3cd; border-radius: 5px;">
            <p><strong>安全提示：</strong></p>
            <p>为确保账号安全，同一账号只能在一个设备上登录。</p>
            <p>如果您在其他地方登录，当前会话将会失效。</p>
        </div>
        <% } %>
    </div>
</body>
</html>

